if (SERVER) then
	AddCSLuaFile( "qhud.lua" )
	AddCSLuaFile( "client/functions.lua" )
	AddCSLuaFile( "client/scoreboard.lua" )
	AddCSLuaFile( "client/browser.lua" )
	AddCSLuafile( "client/chatbox.lua" )
end

concommand.Add( "check", function(ply)
	print( "Script Enforcer is set to "..ply:GetInfoNum("sv_scriptenforcer").." and sv_cheats is set to "..ply:GetInfoNum("sv_cheats").."." )
end )

hook.Add( "PlayerInitialSpawn", "PlayerSpawn", function( ply )

local addon = {}
addon.Name = "Quick Hud - Official"
addon.Author = "Jova"
addon.Version = "1.00"

	print( "" )
	print( "------------------------" )
	print( "========================" )
	print( addon.Name.." - version "..addon.Version )
	print( "Created by " ..addon.Author )
	print( "========================" )
	print( "------------------------" )
	print( "" )
	
	--ply:SetMaxHealth( 200, true )
	ply:ConCommand( "browser" )	
end)

hook.Add( "PlayerSpawn", "PlayerSpawn", function( ply )
	--ply:SetHealth( 200 )
end)

function QuickHudbase()
	if(LocalPlayer():GetActiveWeapon() == NULL or LocalPlayer():GetActiveWeapon() == "Camera") then return end
	if !LocalPlayer():Alive() then return end
	
local pl = LocalPlayer()

--[[if input.IsMouseDown( MOUSE_MIDDLE ) then
	gui.EnableScreenClicker(!vgui.CursorVisible())
end]]

local Speed = pl:GetVelocity():Length() / 25.2
local health = pl:Health()
local bgcolor = Color( 65, 65, 65, 255 )
local clip1 = pl:GetActiveWeapon():Clip1()
local clip2 = pl:GetAmmoCount(pl:GetActiveWeapon():GetSecondaryAmmoType())
local mclip = pl:GetAmmoCount(pl:GetActiveWeapon():GetPrimaryAmmoType())

    Ammo = {}
    Ammo["weapon_crowbar"] = 0
    Ammo["weapon_physcannon"] = 0
    Ammo["weapon_physgun"] = 0
    Ammo["weapon_pistol"] = 18
    Ammo["weapon_357"] = 6
    Ammo["weapon_smg1"] = 45
    Ammo["weapon_ar2"] = 30
    Ammo["weapon_crossbow"] = 1
	Ammo["weapon_shotgun"] = 6
    Ammo["weapon_frag"] = 0
    Ammo["weapon_rpg"] = 0
	Ammo["gmod_tool"] = 0
	Ammo["gmod_camera"] = 0

	--draw.RoundedBox( 0, 0, 0, ScrW(), 36, bgcolor)
	DrawBox( 0, 0, ScrW(), 36, bgcolor, 2 )

draw.RoundedBox( 0, 130, 9, 150, 18, Color( 125, 125, 125, 255 ))
	draw.RoundedBox(0, 130, 9, math.Clamp(health, 0, 100)*1.50, 18, Color( 195, 0, 0, 255 ))
	surface.SetDrawColor( Color( 65, 65, 65, 255 ))
surface.DrawOutlinedRect( 130, 9, 150, 18 )
draw.SimpleText("Health: "..health, "TabLarge", 133, 11, Color( 255, 255, 255, 255 ),0,0)

		draw.RoundedBox( 0, 310, 9, 150, 18, Color( 125, 125, 125, 255 ))
		draw.RoundedBox( 0, 310, 9, math.Clamp(Speed, 0, 120)*1.30, 18, Color( 0, 175, 15, 255 ))
		surface.SetDrawColor( Color( 65, 65, 65, 255 ))
		surface.DrawOutlinedRect( 310, 9, 150, 18 )
		draw.SimpleText(math.Round(Speed) .. " MPH", "TabLarge", 313, 11, Color( 255, 255, 255, 255 ),0,0)
	
	if pl:InVehicle() then
		local vSpeed = pl:GetVehicle():GetVelocity():Length() / 25.2
		draw.RoundedBox( 0, 310, 9, 150, 18, Color( 125, 125, 125, 255 ))
		draw.RoundedBox( 0, 310, 9, math.Clamp(vSpeed, 0, 120)*1.30, 18, Color( 0, 175, 15, 255 ))
		surface.SetDrawColor( Color( 65, 65, 65, 255 ))
		surface.DrawOutlinedRect( 310, 9, 150, 18 )
		draw.SimpleText(math.Round(vSpeed) .. " MPH", "TabLarge", 313, 11, Color( 255, 255, 255, 255 ),0,0)
	end

surface.SetTexture( surface.GetTextureID( "vgui/loading-logo" ) )
	surface.SetDrawColor( 255, 255, 255, 255 )
	surface.DrawTexturedRect( 1.5, 1.5, 33, 33 )
surface.SetTexture( surface.GetTextureID( "vgui/loading-rotate" ) )
	surface.SetDrawColor( 255, 255, 255, 255 )
	surface.DrawTexturedRectRotated( 17.5, 17.5, 33, 33, CurTime()*90 )

	draw.SimpleText(os.date( "%a, %I:%M:%S %p" ), "DefaultSmall", 42, 7, Color( 135, 135, 135, 255 ),0,0)
	draw.SimpleText(os.date( "%m/%d/20%y" ), "DefaultSmall", 56.4, 19, Color( 135, 135, 135, 255 ),0,0)

if pl:GetActiveWeapon():GetClass() == "gmod_tool" or pl:GetActiveWeapon():GetClass() == "gmod_camera" then
	return false
	else
end
		
	if pl:GetActiveWeapon():GetClass() == "weapon_rpg" or pl:GetActiveWeapon():GetClass() == "weapon_frag" then
		draw.RoundedBox( 0, 490, 9, 150, 18, Color( 125, 125, 125, 255 ))
		surface.SetDrawColor( Color( 65, 65, 65, 255 ))
		surface.DrawOutlinedRect( 490, 9, 150, 18 )
		draw.SimpleText("["..mclip.."]", "TabLarge", 493, 11, Color( 255, 255, 255, 255 ),0,0)
	elseif pl:GetActiveWeapon():GetClass() == "weapon_physgun" or pl:GetActiveWeapon():GetClass() == "weapon_physcannon" or pl:GetActiveWeapon():GetClass() == "weapon_crowbar" then
		draw.RoundedBox( 0, 490, 9, 150, 18, Color( 125, 125, 125, 255 ))
		surface.SetDrawColor( Color( 65, 65, 65, 255 ))
		surface.DrawOutlinedRect( 490, 9, 150, 18 )
		draw.SimpleText("None", "TabLarge", 493, 11, Color( 255, 255, 255, 255 ),0,0)
	else
		draw.RoundedBox( 0, 490, 9, 150, 18, Color( 125, 125, 125, 255 ))
		surface.SetDrawColor( Color( 65, 65, 65, 255 ))
		surface.DrawOutlinedRect( 490, 9, 150, 18 )
		draw.SimpleText("["..clip1.."/"..mclip.."] "..clip2, "TabLarge", 493, 11, Color( 255, 255, 255, 255 ),0,0)
	end

if pl:IsAdmin() then
draw.RoundedBox( 0, ScrW()-124, 1, 100, 17, Color( 68, 87, 101, 255 ) )
draw.SimpleText( "QAdmin Menu", "Default", ScrW()-108, 8, Color( 255, 255, 255, 255 ),TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
	
	if MouseInBox( ScrW()-124, 1, 100, 17 ) then
		draw.RoundedBox( 0 , ScrW() - 124, 1, 100, 17, Color( 255, 255, 255, 60 ) )

		if input.IsMouseDown( MOUSE_LEFT ) then
		draw.RoundedBox( 0 , ScrW() - 124, 1, 100, 17, Color( 0, 55, 195, 60 ) )
-------------------------------------------------- --------------------------------------------------
-------------------------------------------------- --------------------------------------------------
-------------------------------------------------- --------------------------------------------------
	local Admin = vgui.Create( "DFrame" )
		Admin:SetPos( ScrW()*0.32, ScrH()*0.30 )
		Admin:SetSize( 450, 300 )
		Admin:SetTitle( "Quick Admin" )
		Admin:SetVisible( true )
		Admin:SetDraggable( false )
		Admin:ShowCloseButton( true )
		Admin:MakePopup()
		
local PropertySheet = vgui.Create( "DPropertySheet" )
PropertySheet:SetParent( Admin )
PropertySheet:SetPos( 5, 25 )
PropertySheet:SetSize( 440, 270 )
 
local PanelOne = vgui.Create( "DPanel" )
local PanelTwo = vgui.Create( "DPanel" )

--[[local BanList = vgui.Create("DComboBox", PanelTwo)
	BanList:SetPos(5, 5)  
	BanList:SetSize(105, PropertySheet:GetTall()-45)
	BanList:SetMultiple( false )]]
	
local ComboBox = vgui.Create("DComboBox", PanelOne)  
	ComboBox:SetPos(5, 5)  
	ComboBox:SetSize(105, PropertySheet:GetTall()-45)
	ComboBox:SetMultiple( false )
		for k,v in pairs(player.GetAll()) do  
		ComboBox:AddItem(v:Nick())
	end
	
local ComboBox2 = vgui.Create("DComboBox", PanelOne)
	ComboBox2:SetPos(109, 5)  
	ComboBox2:SetSize(25, PropertySheet:GetTall()-45)
	ComboBox2:SetMultiple( false )
		for k,v in pairs(player.GetAll()) do  
		ComboBox2:AddItem(v:UserID())
	end

local Selection = vgui.Create( "DPanel", PanelOne )
Selection:SetPos( 150, 5 )
Selection:SetSize( PropertySheet:GetWide(), PropertySheet:GetTall() )
Selection.Paint = function()
	draw.RoundedBox( 0, 0, 0, PropertySheet:GetWide() - 180, PropertySheet:GetTall() - 75, Color( 50, 50, 50, 255 ) )
    if ComboBox:GetSelectedItems() and ComboBox:GetSelectedItems()[1] then
		draw.SimpleText( "Selection: "..ComboBox:GetSelectedItems()[1]:GetValue(), "Default", 5, 5, Color( 255, 255, 255, 255 ) )
    end
end

local kbutton = vgui.Create( "DButton", Selection )
	kbutton:SetSize( 100, 30 )
	kbutton:SetPos( 5, 30 )
	kbutton:SetText( "Kick" )
	kbutton.DoClick = function( button )
		RunConsoleCommand( unpack( string.Explode( " ", "kick "..ComboBox:GetSelectedItems()[1]:GetValue() ) ) )
	end
	
local bbutton = vgui.Create( "DButton", Selection )
	bbutton:SetSize( 100, 30 )
	bbutton:SetPos( 5, 65 )
	bbutton:SetText( "Ban for..." )
	bbutton.DoClick = function( button )
	local punishment = DermaMenu()
		punishment:AddOption("1 Hour", function()
			RunConsoleCommand( "banid2", "60", ComboBox2:GetSelectedItems()[1]:GetValue() )
			RunConsoleCommand( "kickid2", ComboBox2:GetSelectedItems()[1]:GetValue(), "Banned for one hour." )
			Admin:SetVisible( false )
		end )
		punishment:AddOption("1 Day", function()
			RunConsoleCommand( "banid2", "1440", ComboBox2:GetSelectedItems()[1]:GetValue() )
			RunConsoleCommand( "kickid2", ComboBox2:GetSelectedItems()[1]:GetValue(), "Banned for one day." )
			Admin:SetVisible( false )
			for k,v in pairs(player.GetAll()) do  
				BanList:AddItem(ComboBox2:GetSelectedItems()[1]:GetValue())
			end
		end )
		--[[punishment:AddOption("Permanently (NOT RECOMMENDED)", function()
			for k,v in pairs(player.GetAll()) do  
				BanList:AddItem(ComboBox2:GetSelectedItems()[1]:GetValue())
			end
			RunConsoleCommand( "banid2", "0", ComboBox2:GetSelectedItems()[1]:GetValue() )
			RunConsoleCommand( "kickid2", ComboBox2:GetSelectedItems()[1]:GetValue(), "Permanently banned." )
			Admin:SetVisible( false )
		end )]]
		punishment:Open()
	end
	
	local cbutton = vgui.Create( "DButton", Selection )
	cbutton:SetSize( 100, 30 )
	cbutton:SetPos( 5, 100 )
	cbutton:SetText( "Cheat Check" )
	cbutton.DoClick = function( button )
	
	local dframe = vgui.Create("DFrame")
	dframe:SetSize(ScrW() / 2, ScrH() / 3)
	dframe:SetTitle("Check")
	dframe:Center()
	dframe:MakePopup()
	dframe:SetDraggable( false )

	local dlistview = vgui.Create("DListView")
	dlistview:SetParent(dframe)
	dlistview:SetPos(0, 22)
    dlistview:SetSize(dframe:GetWide(), dframe:GetTall() - 44) 
	dlistview:AddColumn("Name")
	dlistview:AddColumn("sv_scriptenforcer")
	dlistview:AddColumn("sv_cheats")

	for k,v in pairs(player.GetAll()) do
		dlistview:AddLine(v:GetName(), v:GetInfoNum("sv_scriptenforcer"), v:GetInfoNum("sv_cheats"))
	end
dlistview.OnRowSelected = function(self, row)
	local confirmation = DermaMenu()
		confirmation:AddOption("Kick?", function()
			RunConsoleCommand( "kick", self:GetLine(row):GetValue(1) )
		end )
		confirmation:Open()
	end
end

PropertySheet:AddSheet( "Basic Administration", PanelOne, "gui/silkicons/shield", false, false, "Kick, Ban, Etc" )
PropertySheet:AddSheet( "Advanced Administration", PanelTwo, "gui/silkicons/shield", false, false, "Extra Things" )
-------------------------------------------------- --------------------------------------------------
-------------------------------------------------- --------------------------------------------------
-------------------------------------------------- --------------------------------------------------
			end
		end
draw.RoundedBox( 0, ScrW() - 228, 1, 100, 17, Color( 68, 87, 101, 255 ) )
draw.SimpleText( "Web Browser", "Default", ScrW()-210, 8, Color( 255, 255, 255, 255 ),TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )

	if MouseInBox( ScrW() - 228, 1, 100, 17 ) then
		draw.RoundedBox( 0, ScrW() - 228, 0, 100, 17, Color( 255, 255, 255, 60 ) )

		if input.IsMouseDown( MOUSE_LEFT ) then
			draw.RoundedBox( 0, ScrW() - 228, 1, 100, 17, Color( 0, 55, 195, 60 ) )
			RunConsoleCommand( "browser" )
			end
		end
	else
draw.RoundedBox( 0, ScrW() - 124, 1, 100, 17, Color( 68, 87, 101, 255 ) )
draw.SimpleText( "Web Browser", "Default", ScrW()-108, 8, Color( 255, 255, 255, 255 ),TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )

	if MouseInBox( ScrW() - 124, 1, 100, 17 ) then
		draw.RoundedBox( 0, ScrW() - 124, 1, 100, 17, Color( 255, 255, 255, 60 ) )

		if input.IsMouseDown( MOUSE_LEFT ) then
			draw.RoundedBox( 0, ScrW() - 124, 1, 100, 17, Color( 0, 55, 195, 60 ) )
			RunConsoleCommand( "browser" )
			end
		end
	end
end
hook.Add( "HUDPaint", "Hud", QuickHudbase )

function hidehud( hud ) for k, v in pairs{ "CHudHealth", "CHudBattery", "CHudAmmo", "CHudSecondaryAmmo" } do if hud == v then return false end; end end; hook.Add( "HUDShouldDraw", "hidehud", hidehud )